<?php

/**
 * @Author: Maowenfu
 * @Date:   2020-10-14 10:41:34
 * @Last Modified by:   Mr.Mao
 * @Last Modified time: 2021-08-30 09:55:28
 */
namespace app\member\model;
use app\BaseModel;
use think\facade\Cache;
//*------------------------------------------------------ */
//-- 游客等级表
/*------------------------------------------------------ */
class UsersLevelAgentModel extends BaseModel
{
	protected $table = 'users_level_agent';
	public  $pk = 'id';
	protected static $mkey = 'users_level_agent_list';
	
	 /*------------------------------------------------------ */
	//-- 清除缓存
	/*------------------------------------------------------ */ 
	public function cleanMemcache($user_id){

		$mkeys = self::$mkey.'_'.$user_id;

		Cache::rm($mkeys);
	}
	/*------------------------------------------------------ */
	//-- 获取列表
	/*------------------------------------------------------ */ 
	public  function getRows($user_id){
		$mkeys = self::$mkey.'_'.$user_id;
		$data = Cache::get($mkeys);
		if (empty($data) == false){
			return $data;
		}
		$rows = $this->field('*')->where('user_id',$user_id)->order('id ASC')->select()->toArray();		
		foreach ($rows as $row){
			$data[$row['level_id']][] = $row;
		}
		Cache::set($mkeys,$data,600);
		return $data;
	}
	
}
